﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Timer = System.Windows.Threading.DispatcherTimer;

namespace MiniMascota
{
    /// <summary>
    /// Lógica de interacción para UserControl1.xaml
    /// </summary>
    public partial class TimerProgressBar : UserControl
    {

        Timer t1;
        string etiqueta;

        public string Etiqueta // refactorizar/encapsular campo
        {
            get { return etiqueta; }
            set { etiqueta = value;
            this.label1.Content = value;
            }
        }

        double incremento;

        public double Incremento
        {
            get { return incremento; }
            set { incremento = value; }
        }

        int intervalo;

        public int Intervalo
        {
            get { return intervalo; }
            set { intervalo = value;
            t1.Interval = TimeSpan.FromMilliseconds(intervalo);
            }
        }

        Brush colorFondo;

        public Brush ColorFondo
        {
            get { return colorFondo; }
            set { colorFondo = value;
            progressBar1.Foreground = value; 
            }
        }

        double valorInicial;

        public double ValorInicial
        {
            get { return valorInicial; }
            set { valorInicial = value;
            this.progressBar1.Value = value;
            }
        }


        public TimerProgressBar()
        {
            InitializeComponent();
            incremento = -1.0;
            intervalo = 1000;
            t1 = new Timer();
            t1.Tick += new EventHandler(TickReloj2);
            t1.Interval = TimeSpan.FromMilliseconds(intervalo);
            t1.Start();

        }

        private void TickReloj2(object o, EventArgs e) {
            this.progressBar1.Value += this.incremento;
        }
    }
}
